<?php
require_once($_SERVER["DOCUMENT_ROOT"]."/sys/includes/const.inc.php");
header('Content-Type: text/javascript; charset=utf-8');
?>
var VL_WEB_MANAGER_MODULES="<?=VL_WEB_MANAGER_MODULES?>";
var ajaxSTOP=false;

var mfuncs={
	siteTree	:	{
		refresh	:	function() {
			$.vlcms.manager.siteTree.node("/", "sitetree", true);
		},
		node	:	function(p, place, refresh) {
			if(refresh==true || $("#"+place).html()=="") {
				$.ajax({
					cache: false,
					type: "POST",
					url: VL_WEB_MANAGER_MODULES+"sitetree/ajaxtree.php",
					data: {path: p},
					success: function(data) {
						$("#"+place).html(data);
						$("#"+place+"_img").attr("src", "/manager/themes/smoothness/images/tree_minus.png");
						$("#"+place+"_img").attr("alt", "[-]");
					}
				});
			} else {
				$("#"+place).html("");
				$("#"+place+"_img").attr("src", "/manager/themes/smoothness/images/tree_plus.png");
				$("#"+place+"_img").attr("alt", "[+]");
			}
		}
	}
};

(function($) {
	$.vlcms={
		manager	: mfuncs
	};
}) (jQuery);

$(document).ready(function() {
	$(".mgr_buttonset").buttonset();
	$(".mgr_tabs").tabs();
		
	//Right top menu buttons
	$("#btn_profile").button("option", "icons", {primary: "ui-icon-person"});
	$("#btn_messages").button("option", "icons", {primary: "ui-icon-mail-closed"});
	$("#btn_exit").button();
			
	//Site tree
	$("#btn_sitetree_create").button("option", "icons", {primary: "ui-icon-document", secondary: "ui-icon-triangle-1-s"});
	$("#btn_sitetree_refresh").button("option", "icons", {primary: "ui-icon-refresh"});
	//$("#btn_sitetree_refresh").click($.vlcms.manager.siteTree.refresh());
	//$.vlcms.manager.siteTree.refresh();
});